/**
  ******************************************************************************
  * @file    User/user.c
  * @author  JUSHENG Application Team
  * @version V1.0.4
  * @date    12-14-2021
  * @brief   Main program body
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2021 JUSHENG</center></h2>
  *
  *
  ******************************************************************************
  */ 

/* Includes ------------------------------------------------------------------*/
#include "include.h"
#include "user.h"
#include "tk_cfg.h"

/** @addtogroup Template_Project
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
 
/**
  * @brief  WDT initialization function
  * @param  None
  * @retval None
  */
void wdt_init(void)
{
    TYPE_LL_WDT_INIT wdt_init;
    NVIC_InitTypeDef nvic;
    /* Configuring system interrupts for the wdt */
    nvic.NVIC_IRQChannel = WDT_IRQn;
    nvic.NVIC_IRQChannelPriority = 0;
    nvic.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvic);

    /* Initialize the relevant variables  */
    memset(&wdt_init, 0x0, sizeof(wdt_init));
    wdt_init.mode = LL_WDT_RMODE_RST;
    wdt_init.psr = LL_WDT_PSR_512DIV_4S;  /* about 4s */
    ll_wdt_init(WDT, &wdt_init);

}

/**
  * @brief  WDT start function
  * @param  None
  * @retval None
  */
void wdt_start(void)
{
    ll_wdt_start(WDT);
}

/**
  * @brief  WDT data handle function
  * @param  None
  * @retval None
  */
void wdt_handle(void)
{
    while(1) {
        ll_wdt_feed(WDT);
    }
}

/**
  * @brief  WDT stop function
  * @param  None
  * @retval None
  */
void wdt_stop(void)
{
    ll_wdt_stop(WDT);
}

/**
  * @brief  WDT detele init function
  * @param  None
  * @retval None
  */
void wdt_deinit(void)
{
    ll_wdt_deinit(WDT);
    NVIC_DisableIRQ(WDT_IRQn);
}

/**
  * @}
  */

/*************************** (C) COPYRIGHT 2021 JUSHENG ***** END OF FILE *****/
